package com.sai.jsai;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author jisai
 * @version 0.0.1
 * @Description 权限模块启动类
 * @createTime 2024/09/21
 */
@Slf4j
@SpringBootApplication
public class JSaiAuthApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(JSaiAuthApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (StrUtil.isEmpty(path)) {
            path = "";
        }

        log.info("""
                \n----------------------------------------------------------\t
                Application  is running! Access URLs:\t
                Local   访问网址: \thttp://localhost:{}{}\t
                External访问网址: \thttp://{}:{}{}\t
                Swagger2访问地址: \thttp://localhost:{}{}/doc.html\t
                ----------------------------------------------------------
                """, port, path,
                ip, port, path,
                port, path
        );
    }

}
